import http from 'src/api/http';
import { UserAPI } from 'src/api/urls';
import {
  ILoginReqParams,
  IGetUserInfoResData,
  IUserActionReqData,
  IQueryUserReqParams,
  IUserInfo,
} from 'src/interface';

export const login = (data: ILoginReqParams) => {
  return http.post<string>(UserAPI.LOGIN, { data });
};

export const getUserInfo = () => {
  return http.get<IGetUserInfoResData>(UserAPI.USER_INFO);
};

export const AddUser = (data: IUserActionReqData) => {
  return http.post<IUserInfo>(UserAPI.USER_ADD, { data });
};

export const UpdateUser = (data: IUserActionReqData) => {
  return http.put<IUserInfo>(UserAPI.USER_UPDATE, { data });
};

export const getUserList = (params: IQueryUserReqParams) => {
  return http.get<IUserInfo[]>(UserAPI.USER_PAGE, { params });
};

export const DeleteUser = (data: string[]) => {
  return http.delete(UserAPI.USER_DELETE, { data });
};
